package org.example.myleet.p507;

public class Solution {
    public boolean checkPerfectNumber(int num) {
        int sum = 0, end = num;
        for (int i = 1; i < end;) {
            if (num % i == 0) {
                sum += i;
                end = num / i;
                if (end != num) {
                    sum += end;
                }
            }
            ++i;
        }
        return sum == num;
    }
}
